package unimelb.filesync.client.protocol;

import javax.crypto.SecretKey;

import unimelb.filesync.common.crypto.CryptoUtils;
import unimelb.filesync.common.misc.ProtocolContext;
import unimelb.filesync.common.protocol.IFileSyncPhase;

public class CreateSecretKeyAndInitVectorPhase implements IFileSyncPhase {

    private final ProtocolContext context;

    private final CryptoUtils cryptoUtils;

    public CreateSecretKeyAndInitVectorPhase(ProtocolContext context) {
        super();
        this.context = context;
        this.cryptoUtils = new CryptoUtils();
    }

    @Override
    public void execute() {
        System.out.println("Generating secret key and init vector");
        
        final SecretKey key = cryptoUtils.createAesKey();

        context.addObject(ProtocolContext.SECRET_KEY, key);
    }

}
